package com.wuhunyu.controller;


import com.wuhunyu.commonutils.result.CommonResult;
import com.wuhunyu.service.EduSubjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.web.multipart.MultipartFile;

/**
 * <p>
 * 课程科目 前端控制器
 * </p>
 *
 * @author wuhunyu
 * @since 2021-01-16
 */
@RestController
@RequestMapping("/eduSubject")
//@CrossOrigin
public class EduSubjectController {

    @Autowired
    private EduSubjectService eduSubjectService;

    /**
     * 添加课程分类，通过读取excel的方式获取课程名
     * @param file
     * @return
     */
    @PostMapping("/addSubject")
    public CommonResult addSubject(MultipartFile file) {
        return eduSubjectService.addSubject(file, eduSubjectService);
    }

    /**
     * 查询所有课程，树形结构数据
     * @return
     */
    @PostMapping("/selectSubject")
    public CommonResult selectAllSubject() {
        return eduSubjectService.selectAllSubjects();
    }

    /**
     * 查询所有课程，线性结构数据
     * @return
     */
    @GetMapping("/selectSubject")
    public CommonResult selectSubjectsForSelect() {
        return eduSubjectService.selectSubjectsForSelect();
    }

}

